﻿namespace OneWorks.Web.Extension.Configuration
{
    using System.Configuration;

    public class UploadFileSection : ConfigurationSection
    {
        [ConfigurationProperty("MultipleConfig", IsRequired = true)]
        public UploadFileConfigCollection MultipleConfig { get { return base["MultipleConfig"] as UploadFileConfigCollection; } }
    }

    public class UploadFileConfigCollection : ConfigurationElementCollection
    {
        protected override ConfigurationElement CreateNewElement()
        {
            return new UploadFileConfigElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((UploadFileConfigElement)element).Key;
        }

        public override ConfigurationElementCollectionType CollectionType
        {
            get
            {
                return ConfigurationElementCollectionType.AddRemoveClearMap;
            }
        }

        public new UploadFileConfigElement this[string key]
        {
            get
            {
                return (UploadFileConfigElement)BaseGet(key);
            }
        }
    }


    public class UploadFileConfigElement : ConfigurationElement
    {
        [ConfigurationProperty("key", IsKey = true, IsRequired = true)]
        public string Key
        {
            get
            {
                return base["key"].ToString();
            }
        }

        [ConfigurationProperty("format", IsRequired = true)]
        public string Format
        {
            get
            {
                return base["format"].ToString();
            }
        }

        [ConfigurationProperty("virtualPath", IsRequired = true)]
        public string VirtualPath
        {
            get
            {
                return base["virtualPath"].ToString();
            }
        }
    }
}
